package com.exrobot.module.rbt.enums;

import com.exrobot.framework.common.core.ArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum RbtLogTypeEnum implements ArrayValuable<String> {
    // ========== 机器人日志类型 ==========
    PLACE("place", "配餐"),
    ROBOT("robot", "机器人"),
    SITE("site", "餐车点位"),
    LOCK("lock", "餐车锁"),
    LAMP("lamp", "餐车灯"),
    UVLAMP("uvlamp", "紫外线灯"),
    NETWORK("network", "网络"),
    CHARGE("charge", "充电"),
    CLEAN("clean", "清洁模式"),
    CHECK("check", "检测模式"),
    DELIVERY_FOOD("delivery-food", "餐食送达"),
    ORDER("order", "创建订单"),
    OTHER("other", "其他"),
    ;

    /**
     * 类型值
     */
    private final String typeVal;
    /**
     * 类型名
     */
    private final String typeName;

    public static final String[] ARRAYS = Arrays.stream(values()).map(RbtLogTypeEnum::getTypeVal).toArray(String[]::new);

    public static RbtLogTypeEnum validateTypeVal(String typeVal) {
        for (RbtLogTypeEnum typeEnum : RbtLogTypeEnum.values()) {
            if (typeEnum.getTypeVal().equals(typeVal)) {
                return typeEnum;
            }
        }
        throw new IllegalArgumentException("非法类型： " + typeVal);
    }

    public static String getName(String typeVal) {
        for (RbtLogTypeEnum typeEnum : RbtLogTypeEnum.values()) {
            if (typeEnum.getTypeVal().equals(typeVal)) {
                return typeEnum.typeName;
            }
        }
        return "未知";
    }

    @Override
    public String[] array() {
        return ARRAYS;
    }
}
